home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / jas99.bst < prev    next >
Text File  |  1993-07-19  |  28KB  |  1,337 lines

  1. % Attempted hack to create BibTeX `jas' style for BibTeX version 0.99c
  2. % Journal of Atmospheric Science, Journal of Applied Meteorology
  3. % Monthly Weather Review
  4. % by Mike Moran, Dept. of Atmospheric Science, Colorado State University
  5. % based on `newapa' style file.  Changes are documented.  March 9, 1990
  6. % Submitted 20-JUL-1993 by Piotr J. Flatau <pflatau@macao.ucsd.edu>
  7. % e-mail for Mike Moran: <mmoran@cid.aes.doe.ca>
  8. % ========================================================================
  9. %
  10. % BibTeX `newapa' style file for BibTeX version 0.99c, LaTeX version 2.09
  11. % Place it in a file called newapa.bst in the BibTeX search path.  
  12. %(Placing it in the same directory as the LaTeX document should also work.)
  13. % Support for named citations is provided by named.sty
  14.  
  15. % This version was made by modifying the master file made by
  16. % Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU), and the 'named' BibTeX
  17. % style of Peter F. Patel-Schneider.
  18.  
  19. % Copyright (C) 1985, all rights reserved.
  20. % Modifications Copyright 1989, 1990, Stephen N. Spencer
  21. % Copying of this file is authorized only if either
  22. % (1) you make absolutely no changes to your copy, including name, or
  23. % (2) if you do make changes, you name it something other than
  24. % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  25. % This restriction helps ensure that all standard styles are identical.
  26.  
  27. % There are undoubtably bugs in this style.  If you make bug fixes,
  28. % improvements, etc.  please let me know.  My e-mail address is:
  29. %    spencer@heinlein.cgrg.ohio.state.edu
  30. %
  31. %   Citation format: (author-last-name, year)
  32. %             (author-last-name and author-last-name, year)
  33. %             (author-last-name {\em et al.}, year)
  34. %                    (author-last-name)
  35. %             (author-last-name and author-last-name)
  36. %             (author-last-name {\em et al.})
  37. %             (year)
  38. %
  39. %   Reference list ordering: alphabetical by author or whatever passes
  40. %    for author in the absence of one.
  41. %
  42. % This BibTeX style has support for abbreviated author lists and for
  43. %    year-only citations.  This is done by having the citations
  44. %    actually look like
  45. %
  46. %    \citeauthoryear{full-author-info}{abbrev-author-info}{year}
  47. %
  48. % The LaTeX style has to have the following (or similar)
  49. %
  50. %     \let\@internalcite\cite
  51. %     \def\fullcite{\def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
  52. %     \def\fullciteA{\def\citeauthoryear##1##2##3{##1}\@internalcite}
  53. %     \def\shortcite{\def\citeauthoryear##1##2##3{##2, ##3}\@internalcite}
  54. %     \def\shortciteA{\def\citeauthoryear##1##2##3{##2}\@internalcite}
  55. %     \def\citeyear{\def\citeauthoryear##1##2##3{##3}\@internalcite}
  56. %
  57.  
  58. ENTRY
  59.   { address
  60.     author
  61.     booktitle
  62.     chapter
  63.     edition
  64.     editor
  65.     howpublished
  66.     institution
  67.     journal
  68.     key
  69. %   month
  70.     note
  71.     number
  72.     organization
  73.     pages
  74.     publisher
  75.     school
  76.     series
  77.     title
  78.     type
  79.     volume
  80.     year
  81.   }
  82.   {}
  83.   { label extra.label sort.label }
  84.  
  85. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  86.  
  87. FUNCTION {init.state.consts}
  88. { #0 'before.all :=
  89.   #1 'mid.sentence :=
  90.   #2 'after.sentence :=
  91.   #3 'after.block :=
  92. }
  93.  
  94. STRINGS { s t u }
  95.  
  96. %%  Added this function March 9, 1990.  Used in FUNCTION format.vol.num.pages
  97. FUNCTION {boldcize}
  98. { 's :=
  99.   s "" =
  100.     { "" }
  101.     { "{\bf " s * "}" * }
  102.   if$
  103. }                           
  104.  
  105. FUNCTION {output.nonnull}
  106. { 's :=
  107.   output.state mid.sentence =
  108.     { ", " * write$ }
  109.     { output.state after.block =
  110.     { add.period$ write$
  111.       newline$
  112.       "\newblock " write$
  113.     }
  114.     { output.state before.all =
  115.         'write$
  116.         { add.period$ " " * write$ }
  117.       if$
  118.     }
  119.       if$
  120.       mid.sentence 'output.state :=
  121.     }
  122.   if$
  123.   s
  124. }
  125.  
  126. %% Added this entire function based on JAS98.BST  (March 10, 1990)
  127. FUNCTION {output.nonnull1}
  128. { 's :=
  129.   output.state mid.sentence =
  130.     { ", " * write$ }
  131.     { output.state after.block =
  132.     {  write$                              %% This is only difference
  133.       newline$
  134.       "\newblock " write$
  135.     }
  136.     { output.state before.all =
  137.         'write$
  138.         { add.period$ " " * write$ }
  139.       if$
  140.     }
  141.       if$
  142.       mid.sentence 'output.state :=
  143.     }
  144.   if$
  145.   s
  146. }
  147.  
  148. FUNCTION {output}
  149. { duplicate$ empty$
  150.     'pop$
  151.     'output.nonnull
  152.   if$
  153. }
  154.  
  155. FUNCTION {output.check}
  156. { 't :=
  157.   duplicate$ empty$
  158.     { pop$ "empty " t * " in " * cite$ * warning$ }
  159.     'output.nonnull
  160.   if$
  161. }
  162.  
  163. %% Added this function based on JAS98.BST  (March 10, 1990)
  164. FUNCTION {output.check1}
  165. { 't :=
  166.   duplicate$ empty$
  167.     { pop$ "empty " t * " in " * cite$ * warning$ }
  168.     'output.nonnull1               %% Only difference
  169.   if$
  170. }
  171.  
  172. FUNCTION {output.year.check}
  173. { year empty$
  174.      { "empty year in " cite$ * warning$ }
  175.      { write$
  176. %%        " (" year * extra.label * ") " *
  177.                 ", " year * extra.label * ": " *
  178. %%                                                      March 9, 1990
  179.         mid.sentence 'output.state :=
  180.      }
  181.   if$
  182. }
  183.  
  184. FUNCTION {output.bibitem}
  185. { newline$
  186.  
  187.   "\bibitem[" write$
  188.   label write$
  189.   "]{" write$
  190.   cite$ write$
  191.   "}" write$
  192.   newline$
  193.   ""
  194.   before.all 'output.state :=
  195. }
  196.  
  197. FUNCTION {fin.entry}
  198. { add.period$
  199.   write$
  200.   newline$
  201. }
  202.  
  203. FUNCTION {new.block}
  204. { output.state before.all =
  205.     'skip$
  206.     { after.block 'output.state := }
  207.   if$
  208. }
  209.  
  210. FUNCTION {new.sentence}
  211. { output.state after.block =
  212.     'skip$
  213.     { output.state before.all =
  214.     'skip$
  215.     { after.sentence 'output.state := }
  216.       if$
  217.     }
  218.   if$
  219. }
  220.  
  221. FUNCTION {not}
  222. {   { #0 }
  223.     { #1 }
  224.   if$
  225. }
  226.  
  227. FUNCTION {and}
  228. {   'skip$
  229.     { pop$ #0 }
  230.   if$
  231. }
  232.  
  233. FUNCTION {or}
  234. {   { pop$ #1 }
  235.     'skip$
  236.   if$
  237. }
  238.  
  239. FUNCTION {new.block.checka}
  240. { empty$
  241.     'skip$
  242.     'new.block
  243.   if$
  244. }
  245.  
  246. FUNCTION {new.block.checkb}
  247. { empty$
  248.   swap$ empty$
  249.   and
  250.     'skip$
  251.     'new.block
  252.   if$
  253. }
  254.  
  255. FUNCTION {new.sentence.checka}
  256. { empty$
  257.     'skip$
  258.     'new.sentence
  259.   if$
  260. }
  261.  
  262. FUNCTION {new.sentence.checkb}
  263. { empty$
  264.   swap$ empty$
  265.   and
  266.     'skip$
  267.     'new.sentence
  268.   if$
  269. }
  270.  
  271. FUNCTION {field.or.null}
  272. { duplicate$ empty$
  273.     { pop$ "" }
  274.     'skip$
  275.   if$
  276. }
  277.  
  278. FUNCTION {emphasize}
  279. { duplicate$ empty$
  280.     { pop$ "" }
  281.     { "{\em " swap$ * "}" * }
  282.   if$
  283. }
  284.  
  285. INTEGERS { nameptr namesleft numnames }
  286.  
  287. FUNCTION {format.names}
  288. { 's :=
  289.   #1 'nameptr :=        % nameptr = 1;
  290.   s num.names$ 'numnames :=    % numnames = num.name$(s);
  291.   numnames 'namesleft :=
  292.     { namesleft #0 > }
  293.  
  294.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=
  295.  
  296.       nameptr #1 >
  297.         { namesleft #1 >
  298.               { ", " * t * }
  299.                { numnames #2 >
  300.                     { "," * }
  301.                     'skip$
  302.                   if$
  303.                   t "others" =
  304.                         { " et~al." * }
  305.                         { " and " * t * }
  306.                       if$
  307.                 }
  308.                if$
  309.              }
  310.             't
  311.         if$
  312.         nameptr #1 + 'nameptr :=            % nameptr += 1;
  313.         namesleft #1 - 'namesleft :=            % namesleft =- 1;
  314.     }
  315.   while$
  316. }
  317.  
  318. %% Added this entire function based on JAS98.BST  (March 10, 1990)
  319. FUNCTION {format.names.reverse1}
  320. { 's :=
  321.   #1 'nameptr :=        % nameptr = 1 (name pointer variable);
  322.   s num.names$ 'numnames :=    % numnames = num.name$(s);
  323.   numnames 'namesleft :=        % namesleft = numnames (names left variable);
  324.     { namesleft #0 > }
  325.  
  326. %% So long as "namesleft" is positive, execute following function
  327.     { 
  328. %%  s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % Set name format
  329.  
  330.       nameptr #1 >
  331. %%           ** Co-authors section
  332.         { 
  333.      s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=   % Set name format
  334.                         namesleft #1 >
  335. %%                    ** Not last author
  336.               { ", " * t * }
  337. %%                    ** Last author
  338.                { numnames #2 >
  339.                     { "," * }
  340.                     'skip$
  341.                   if$
  342.                   t "others" =
  343.                         { " et~al." * }
  344.                         { " and " * t * }
  345.                       if$
  346.                 }
  347.                if$
  348.              }
  349. %%               **  First author section
  350.      { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % Set name format
  351.             t
  352.                     }      
  353.         if$
  354.         nameptr #1 + 'nameptr :=           % nameptr += 1;
  355.         namesleft #1 - 'namesleft :=               % namesleft =- 1;
  356.     }
  357.   while$
  358. }
  359.  
  360. FUNCTION {format.authors}
  361. { author empty$
  362.     { "" }
  363. %%    { author format.names }
  364.     { author format.names.reverse1 }
  365. %%                                              March 10, 1990
  366.   if$
  367. }
  368.  
  369. FUNCTION {format.key}
  370. { empty$
  371.     { key field.or.null }
  372.     { "" }
  373.   if$
  374. }
  375.  
  376. FUNCTION {format.editors}
  377. { editor empty$
  378.     { "" }
  379.     { editor format.names
  380.       editor num.names$ #1 >
  381.     { ", editors" * }
  382.     { ", editor" * }
  383.       if$
  384.     }
  385.   if$
  386. }
  387.  
  388. FUNCTION {format.title}
  389. { title empty$
  390.     { "" }
  391.  
  392.     { title "t" change.case$ }
  393.  
  394.   if$
  395. }
  396.  
  397. FUNCTION {n.dashify}
  398. { 't :=
  399.   ""
  400.     { t empty$ not }
  401.     { t #1 #1 substring$ "-" =
  402.     { t #1 #2 substring$ "--" = not
  403.         { "--" *
  404.           t #2 global.max$ substring$ 't :=
  405.         }
  406.         {   { t #1 #1 substring$ "-" = }
  407.         { "-" *
  408.           t #2 global.max$ substring$ 't :=
  409.         }
  410.           while$
  411.         }
  412.       if$
  413.     }
  414.     { t #1 #1 substring$ *
  415.       t #2 global.max$ substring$ 't :=
  416.     }
  417.       if$
  418.     }
  419.   while$
  420. }
  421.  
  422. FUNCTION {format.btitle}
  423. { title emphasize
  424. }
  425.  
  426. FUNCTION {tie.or.space.connect}
  427. { duplicate$ text.length$ #3 <
  428.     { "~" }
  429.     { " " }
  430.   if$
  431.   swap$ * *
  432. }
  433.  
  434. FUNCTION {either.or.check}
  435. { empty$
  436.     'pop$
  437.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  438.   if$
  439. }
  440.  
  441. FUNCTION {format.bvolume}
  442. { volume empty$
  443.     { "" }
  444.     { "volume" volume tie.or.space.connect
  445.       series empty$
  446.     'skip$
  447.     { " of " * series emphasize * }
  448.       if$
  449.       "volume and number" number either.or.check
  450.     }
  451.   if$
  452. }
  453.  
  454. FUNCTION {format.number.series}
  455. { volume empty$
  456.     { number empty$
  457.     { series field.or.null }
  458.     { output.state mid.sentence =
  459.         { "number" }
  460.         { "Number" }
  461.       if$
  462.       number tie.or.space.connect
  463.       series empty$
  464.         { "there's a number but no series in " cite$ * warning$ }
  465.         { " in " * series * }
  466.       if$
  467.     }
  468.       if$
  469.     }
  470.     { "" }
  471.   if$
  472. }
  473.  
  474. FUNCTION {format.edition}
  475. { edition empty$
  476.     { "" }
  477.     { output.state mid.sentence =
  478.     { edition "l" change.case$ " edition" * }
  479.     { edition "t" change.case$ " edition" * }
  480.       if$
  481.     }
  482.   if$
  483. }
  484.  
  485. INTEGERS { multiresult }
  486.  
  487. FUNCTION {multi.page.check}
  488. { 't :=
  489.   #0 'multiresult :=
  490.     { multiresult not
  491.       t empty$ not
  492.       and
  493.     }
  494.     { t #1 #1 substring$
  495.       duplicate$ "-" =
  496.       swap$ duplicate$ "," =
  497.       swap$ "+" =
  498.       or or
  499.     { #1 'multiresult := }
  500.     { t #2 global.max$ substring$ 't := }
  501.       if$
  502.     }
  503.   while$
  504.   multiresult
  505. }
  506.  
  507. FUNCTION {format.pages}
  508. { pages empty$
  509.     { "" }
  510.     { pages multi.page.check
  511. %%    { "pages" pages n.dashify tie.or.space.connect }
  512. %%    { "page" pages tie.or.space.connect }
  513.     {  pages n.dashify tie.or.space.connect }
  514.     {  pages tie.or.space.connect }
  515.       if$
  516.     }
  517.   if$
  518. }
  519.  
  520. FUNCTION {format.vol.num.pages}
  521. %%{ volume field.or.null 
  522. {volume field.or.null boldcize                           %% March 9, 1990
  523.   number empty$
  524.     'skip$
  525.     { "(" number * ")" * *
  526.       volume empty$
  527.     { "there's a number but no volume in " cite$ * warning$ }
  528.     'skip$
  529.       if$
  530.     }
  531.   if$
  532.   pages empty$
  533.     'skip$
  534.     { duplicate$ empty$
  535.     { pop$ format.pages }
  536. %%    { ":" * pages n.dashify * }
  537.         { ", " * pages n.dashify * }                         %%  March 9, 1990
  538.       if$
  539.     }
  540.   if$
  541. }
  542.  
  543. FUNCTION {format.chapter.pages}
  544. { chapter empty$
  545.     'format.pages
  546.     { type empty$
  547.     { "chapter" }
  548.     { type "l" change.case$ }
  549.       if$
  550.       chapter tie.or.space.connect
  551.       pages empty$
  552.     'skip$
  553.     { ", " * format.pages * }
  554.       if$
  555.     }
  556.   if$
  557. }
  558.  
  559. FUNCTION {format.in.ed.booktitle}
  560. { booktitle empty$
  561.     { "" }
  562.     { editor empty$
  563.     { "In " booktitle emphasize * }
  564. %%    { "In " format.editors * ", " * booktitle emphasize * }
  565.       { "In " booktitle emphasize * ", " * format.editors * }
  566. %%                                            March 11, 1990
  567.       if$
  568.     }
  569.   if$
  570. }
  571.  
  572. FUNCTION {format.thesis.type}
  573. { type empty$
  574.     'skip$
  575.     { pop$
  576.       type "t" change.case$
  577.     }
  578.   if$
  579. }
  580.  
  581. FUNCTION {format.tr.number}
  582. { type empty$
  583.     { "Technical Report" }
  584.     'type
  585.   if$
  586.   number empty$
  587.     { "t" change.case$ }
  588.     { number tie.or.space.connect }
  589.   if$
  590. }
  591.  
  592. FUNCTION {format.article.crossref}
  593. { "In"
  594.   "\cite{" * crossref * "}" *
  595. }
  596.  
  597. FUNCTION {format.crossref.editor}
  598. { editor #1 "{vv~}{ll}" format.name$
  599.   editor num.names$ duplicate$
  600.   #2 >
  601.     { pop$ " et~al." * }
  602.     { #2 <
  603.     'skip$
  604.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  605.         { " et~al." * }
  606.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  607.       if$
  608.     }
  609.       if$
  610.     }
  611.   if$
  612. }
  613.  
  614. FUNCTION {format.book.crossref}
  615. { volume empty$
  616.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  617.       "In "
  618.     }
  619.     { "Volume" volume tie.or.space.connect
  620.       " of " *
  621.     }
  622.   if$
  623.   editor empty$
  624.   editor field.or.null author field.or.null =
  625.   or
  626.     { key empty$
  627.     { series empty$
  628.         { "need editor, key, or series for " cite$ * " to crossref " *
  629.           crossref * warning$
  630.           "" *
  631.         }
  632.         { "{\em " * series * "\/}" * }
  633.       if$
  634.     }
  635.     { key * }
  636.       if$
  637.     }
  638.     { format.crossref.editor * }
  639.   if$
  640.   " \cite{" * crossref * "}" *
  641. }
  642.  
  643. FUNCTION {format.incoll.inproc.crossref}
  644. { "In"
  645.   " \cite{" * crossref * "}" *
  646. }
  647.  
  648. FUNCTION {article}
  649. { output.bibitem
  650.   format.authors "author" output.check
  651.   author format.key output                % added
  652.   output.year.check                         % added
  653.   new.block
  654. %%  format.title "title" output.check
  655.   format.title "title" output.check1                       %% March 10, 1990
  656.   new.block
  657.   crossref missing$
  658.     { journal emphasize "journal" output.check
  659.       format.vol.num.pages output
  660.     }
  661.     { format.article.crossref output.nonnull
  662.       format.pages output
  663.     }
  664.   if$
  665.   new.block
  666.   note output
  667.   fin.entry
  668. }
  669.  
  670. FUNCTION {book}
  671. { output.bibitem
  672.   author empty$
  673.     { format.editors "author and editor" output.check }
  674.     { format.authors output.nonnull
  675.       crossref missing$
  676.     { "author and editor" editor either.or.check }
  677.     'skip$
  678.       if$
  679.     }
  680.   if$
  681.   output.year.check                    % added
  682.   new.block
  683. %%  format.btitle "title" output.check
  684.   format.btitle "title" output.check1                      %% March 11, 1990
  685.   crossref missing$
  686.     { format.bvolume output
  687.       new.block
  688.       format.number.series output
  689.       new.sentence
  690.       publisher "publisher" output.check
  691.       address output
  692.       pages output                                   %% March 11, 1990
  693.     }
  694.     { new.block
  695.       format.book.crossref output.nonnull
  696.     }
  697.   if$
  698.   format.edition output
  699.   new.block
  700.   note output
  701.   fin.entry
  702. }
  703.  
  704. FUNCTION {booklet}
  705. { output.bibitem
  706.   format.authors output
  707.   author format.key output                    % added
  708.   output.year.check                        % added
  709.   new.block
  710. %%  format.title "title" output.check
  711.   format.title "title" output.check1                          %% March 11, 1990
  712.   new.block
  713.   howpublished output
  714.   address output
  715.   pages output                                                %% March 11, 1990
  716.   new.block
  717.   note output
  718.   fin.entry
  719. }
  720.  
  721. FUNCTION {inbook}
  722. { output.bibitem
  723.   author empty$
  724.     { format.editors "author and editor" output.check }
  725.     { format.authors output.nonnull
  726.       crossref missing$
  727.     { "author and editor" editor either.or.check }
  728.     'skip$
  729.       if$
  730.     }
  731.   if$
  732.   output.year.check                        % added
  733.   new.block
  734. %%  format.btitle "title" output.check
  735.   format.btitle "title" output.check1                         %% March 11, 1990
  736.   crossref missing$
  737.     { format.bvolume output
  738.       new.block
  739.       format.number.series output
  740.       new.sentence
  741.       publisher "publisher" output.check
  742.       address output
  743. %%    format.chapter.pages "chapter and pages" output.check
  744.       pages output                                            %% March 20, 1990
  745.     }
  746.     { format.chapter.pages "chapter and pages" output.check
  747.       new.block
  748.       format.book.crossref output.nonnull
  749.     }
  750.   if$
  751.   format.edition output
  752.   new.block
  753.   note output
  754.   fin.entry
  755. }
  756.  
  757. FUNCTION {incollection}
  758. { output.bibitem
  759.   format.authors "author" output.check
  760.   author format.key output                    % added
  761.   output.year.check                        % added
  762.   new.block
  763. %%  format.title "title" output.check
  764.   format.title "title" output.check1                          %% March 11, 1990
  765.   new.block
  766.   crossref missing$
  767.     { format.in.ed.booktitle "booktitle" output.check
  768.       format.bvolume output
  769.       format.number.series output
  770. %%      format.chapter.pages output                           %% March 20, 1990
  771.       new.sentence
  772.       publisher "publisher" output.check
  773.       address output
  774.       format.edition output
  775.       pages output                                            %% March 20, 1990
  776.     }
  777.     { format.incoll.inproc.crossref output.nonnull
  778.       format.chapter.pages output
  779.     }
  780.   if$
  781.   new.block
  782.   note output
  783.   fin.entry
  784. }
  785.  
  786. FUNCTION {inproceedings}
  787. { output.bibitem
  788.   format.authors "author" output.check
  789.   author format.key output                    % added
  790.   output.year.check                        % added
  791.   new.block
  792. %%  format.title "title" output.check
  793.   format.title "title" output.check1                          %% March 11, 1990
  794.   new.block
  795.   crossref missing$
  796.     { format.in.ed.booktitle "booktitle" output.check
  797.       format.bvolume output
  798.       format.number.series output
  799. %%      new.sentence                                          %% March 17, 1990
  800.       organization output
  801.       publisher output
  802.       address output
  803.       pages output
  804.      }
  805.     { format.incoll.inproc.crossref output.nonnull
  806.       format.pages output
  807.     }
  808.   if$
  809.   new.block
  810.   note output
  811.   fin.entry
  812. }
  813.  
  814. FUNCTION {conference} { inproceedings }
  815.  
  816. FUNCTION {manual}
  817. { output.bibitem
  818.   format.authors output
  819.   author format.key output                    % added
  820.   output.year.check                        % added
  821.   new.block
  822. %%  format.btitle "title" output.check
  823.   format.btitle "title" output.check1                      %% March 11, 1990
  824.   organization address new.block.checkb
  825.   organization output
  826.   address output
  827.   format.edition output
  828.   pages output                                             %% March 11, 1990
  829.   new.block
  830.   note output
  831.   fin.entry
  832. }
  833.  
  834. FUNCTION {mastersthesis}
  835. { output.bibitem
  836.   format.authors "author" output.check
  837.   author format.key output                % added
  838.   output.year.check                        % added
  839.   new.block
  840. %%  format.title "title" output.check
  841.   format.title "title" output.check1                       %% March 11, 1990
  842.   new.block
  843.   "Master's thesis" format.thesis.type output.nonnull
  844.   school "school" output.check
  845.   address output
  846.   pages output                                             %% March 11, 1990
  847.   new.block
  848.   note output
  849.   fin.entry
  850. }
  851.  
  852. FUNCTION {misc}
  853. { output.bibitem
  854.   format.authors output
  855.   author format.key output                    % added
  856.   output.year.check                        % added
  857.   title howpublished new.block.checkb
  858. %%  format.title output
  859.   format.title "title" output.check1                          %% March 11, 1990
  860.   new.block
  861.   howpublished output
  862.   pages output                                                %% March 11, 1990
  863. %%  new.block                                                 %% March 17, 1990
  864.   note output
  865.   fin.entry
  866. }
  867.  
  868. FUNCTION {phdthesis}
  869. { output.bibitem
  870.   format.authors "author" output.check
  871.   author format.key output                    % added
  872.   output.year.check                        % added
  873.   new.block
  874. %%  format.btitle "title" output.check
  875.   format.btitle "title" output.check1                         %% March 11, 1990
  876.   new.block
  877.   "PhD thesis" format.thesis.type output.nonnull
  878.   school "school" output.check
  879.   address output
  880.   pages output                                               %% March 11, 1990
  881.   new.block
  882.   note output
  883.   fin.entry
  884. }
  885.  
  886. FUNCTION {proceedings}
  887. { output.bibitem
  888.   editor empty$
  889.     { organization output }
  890.     { format.editors output.nonnull }
  891.   if$
  892.   author format.key output                    % added
  893.   output.year.check                        % added
  894.   new.block
  895. %%  format.btitle "title" output.check
  896.   format.btitle "title" output.check1                        %% March 11, 1990
  897.   format.bvolume output
  898.   format.number.series output
  899.   address output
  900.   new.sentence
  901.   organization output
  902.   publisher output
  903.   pages output                                               %% March 11, 1990
  904.   new.block
  905.   note output
  906.   fin.entry
  907. }
  908.  
  909. FUNCTION {techreport}
  910. { output.bibitem
  911.   format.authors "author" output.check
  912.   author format.key output                    % added
  913.   output.year.check                        % added
  914.   new.block
  915. %%  format.title "title" output.check
  916.   format.title "title" output.check1                        %% March 11, 1990
  917.   new.block
  918.   format.tr.number output.nonnull
  919.   institution "institution" output.check
  920.   address output
  921.   pages output                                              %% March 11, 1990
  922.   new.block
  923.   note output
  924.   fin.entry
  925. }
  926.  
  927. FUNCTION {unpublished}
  928. { output.bibitem
  929.   format.authors "author" output.check
  930.   author format.key output                    % added
  931.   output.year.check                        % added
  932.   new.block
  933. %%  format.title "title" output.check
  934.   format.title "title" output.check1                         %% March 11, 1990
  935.   new.block
  936.   note "note" output.check
  937.   fin.entry
  938. }
  939.  
  940. FUNCTION {default.type} { misc }
  941.  
  942. MACRO {jan} {"January"}
  943.  
  944. MACRO {feb} {"February"}
  945.  
  946. MACRO {mar} {"March"}
  947.  
  948. MACRO {apr} {"April"}
  949.  
  950. MACRO {may} {"May"}
  951.  
  952. MACRO {jun} {"June"}
  953.  
  954. MACRO {jul} {"July"}
  955.  
  956. MACRO {aug} {"August"}
  957.  
  958. MACRO {sep} {"September"}
  959.  
  960. MACRO {oct} {"October"}
  961.  
  962. MACRO {nov} {"November"}
  963.  
  964. MACRO {dec} {"December"}
  965.  
  966. MACRO {acmcs} {"ACM Computing Surveys"}
  967.  
  968. MACRO {acta} {"Acta Informatica"}
  969.  
  970. MACRO {cacm} {"Communications of the ACM"}
  971.  
  972. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  973.  
  974. MACRO {ibmsj} {"IBM Systems Journal"}
  975.  
  976. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  977.  
  978. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  979.  
  980. MACRO {ieeetcad}
  981.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  982.  
  983. MACRO {ipl} {"Information Processing Letters"}
  984.  
  985. MACRO {jacm} {"Journal of the ACM"}
  986.  
  987. MACRO {jcss} {"Journal of Computer and System Sciences"}
  988.  
  989. MACRO {scp} {"Science of Computer Programming"}
  990.  
  991. MACRO {sicomp} {"SIAM Journal on Computing"}
  992.  
  993. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  994.  
  995. MACRO {tods} {"ACM Transactions on Database Systems"}
  996.  
  997. MACRO {tog} {"ACM Transactions on Graphics"}
  998.  
  999. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1000.  
  1001. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1002.  
  1003. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1004.  
  1005. MACRO {tcs} {"Theoretical Computer Science"}
  1006.  
  1007. READ
  1008.  
  1009. FUNCTION {sortify}
  1010. { purify$
  1011.   "l" change.case$
  1012. }
  1013.  
  1014. INTEGERS { len }
  1015.  
  1016. FUNCTION {chop.word}
  1017. { 's :=
  1018.   'len :=
  1019.   s #1 len substring$ =
  1020.     { s len #1 + global.max$ substring$ }
  1021.     's
  1022.   if$
  1023. }
  1024.  
  1025. INTEGERS { fullptr numfull fullsleft }
  1026.  
  1027. STRINGS { u1 u2 }
  1028.  
  1029. %FUNCTION {my.full.label}
  1030. %{ 
  1031. %  "foo" 'u :=
  1032. %  u
  1033. %}
  1034.  
  1035. FUNCTION {my.full.label}
  1036. % Initialize 'u1','u2','s'.
  1037.   "" 'u1 :=                                       
  1038.   "" 'u2 :=                     
  1039.   's :=                      
  1040.  
  1041. % Initialize 'fullptr','numfull','fullsleft'.
  1042.   #1 'fullptr :=                         
  1043.   s num.names$ 'numfull :=   
  1044.   numfull 'fullsleft :=          
  1045.  
  1046. % enter the while loop which generates the first-citation information.
  1047. % while we have names left, 
  1048. %     format the next name
  1049. %   if this is the next-to-last name, tack the ampersand on the end
  1050. %   else if this isn't the last name, tack the comma on the end.
  1051. %   concatenate the next name onto the first-citation string.
  1052. %   update the counters.
  1053.  
  1054.   { fullsleft #0 > }
  1055.   { s fullptr "{vv~}{ll}" format.name$ 'u1 :=  
  1056.      fullsleft #2 =
  1057.        { u1 " \& " * 'u1 := }
  1058.       { fullsleft #2 > 
  1059.            { u1 ", " * 'u1 := }
  1060.            'skip$
  1061.          if$
  1062.         }
  1063.     if$
  1064.      u2 u1 * 'u2 :=
  1065.      fullptr #1 + 'fullptr :=         
  1066.      fullsleft #1 - 'fullsleft :=  
  1067.   }
  1068.   while$
  1069.  
  1070. % push 'u2' onto the stack -- our first-citation information.
  1071.   u2        
  1072. }
  1073.  
  1074. FUNCTION {format.lab.names}
  1075. { 's :=                             
  1076.   s #1 "{vv~}{ll}" format.name$        
  1077.   s num.names$ duplicate$
  1078.   #2 >                                
  1079.      { pop$ " et~al." * }            
  1080.      { #2 <
  1081.           'skip$
  1082.           { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1083.                 { "et~al. " * }
  1084.                 { " and " * s #2 "{vv~}{ll}" format.name$ * }
  1085.              if$
  1086.             }
  1087.        if$
  1088.      }
  1089.   if$
  1090. }
  1091.  
  1092. FUNCTION {author.key.label}
  1093. { author empty$
  1094.     { key empty$
  1095.           { cite$ #1 #3 substring$ }
  1096.          'key
  1097.       if$
  1098.     }
  1099.     { author format.lab.names }
  1100.   if$
  1101. }
  1102.  
  1103. FUNCTION {editor.key.label}
  1104. { editor empty$
  1105.     { key empty$
  1106.           { cite$ #1 #3 substring$ }
  1107.           'key
  1108.         if$
  1109.      }
  1110.      { editor format.lab.names }
  1111.   if$
  1112. }
  1113.  
  1114. FUNCTION {author.editor.key.label}
  1115. { author empty$
  1116.     { editor empty$
  1117.           { key empty$
  1118.                { cite$ #1 #3 substring$ }
  1119.              'key
  1120.            if$
  1121.          }
  1122.           { editor format.lab.names }
  1123.       if$
  1124.     }
  1125.     { author format.lab.names }
  1126.   if$
  1127. }
  1128.  
  1129. FUNCTION {calc.label}
  1130. { type$ "book" =
  1131.   type$ "inbook" =
  1132.   or
  1133.     'author.editor.key.label
  1134.     { type$ "proceedings" =
  1135.           'editor.key.label
  1136.           'author.key.label
  1137.         if$
  1138.     }
  1139.   if$
  1140.   duplicate$    
  1141.  
  1142.   author my.full.label  % generate the first-citation information.
  1143.  
  1144.   "\protect\citeauthoryear{" swap$ * "}{" * swap$ * "}{" *
  1145.   year field.or.null purify$ #-1 #4 substring$ *  
  1146.   'label :=
  1147.   year field.or.null purify$ #-1 #4 substring$ *
  1148.   sortify 'sort.label :=
  1149. }
  1150.  
  1151. FUNCTION {sort.format.names}
  1152. { 's :=
  1153.   #1 'nameptr :=
  1154.   ""
  1155.   s num.names$ 'numnames :=
  1156.   numnames 'namesleft :=
  1157.     { namesleft #0 > }
  1158.     { nameptr #1 >
  1159.           { "   " * }
  1160.          'skip$
  1161.       if$
  1162.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  1163.       nameptr numnames = t "others" = and
  1164.           { "et al" * }
  1165.           { t sortify * }
  1166.       if$
  1167.       nameptr #1 + 'nameptr :=
  1168.       namesleft #1 - 'namesleft :=
  1169.     }
  1170.   while$
  1171. }
  1172.  
  1173. FUNCTION {sort.format.title}
  1174. { 't :=
  1175.   "A " #2
  1176.     "An " #3
  1177.       "The " #4 t chop.word
  1178.     chop.word
  1179.   chop.word
  1180.   sortify
  1181.   #1 global.max$ substring$
  1182. }
  1183.  
  1184. FUNCTION {author.sort}
  1185. { author empty$
  1186.     { key empty$
  1187.           { "to sort, need author or key in " cite$ * warning$
  1188.               ""
  1189.          }
  1190.          { key sortify }
  1191.       if$
  1192.     }
  1193.     { author sort.format.names }
  1194.   if$
  1195. }
  1196.  
  1197. FUNCTION {editor.sort}
  1198. { editor empty$
  1199.     { key empty$
  1200.          { "to sort, need editor or key in " cite$ * warning$
  1201.            ""
  1202.          }
  1203.          { key sortify }
  1204.       if$
  1205.     }
  1206.     { editor sort.format.names }
  1207.   if$
  1208. }
  1209.  
  1210. FUNCTION {author.editor.sort}
  1211. { author empty$
  1212.     { editor empty$
  1213.          { key empty$
  1214.              { "to sort, need author, editor, or key in " cite$ * warning$
  1215.                ""
  1216.              }
  1217.              { key sortify }
  1218.            if$
  1219.          }
  1220.          { editor sort.format.names }
  1221.       if$
  1222.    }
  1223.    { author sort.format.names }
  1224.   if$
  1225. }
  1226.  
  1227. FUNCTION {presort}
  1228. { calc.label
  1229.   label sortify
  1230.   "    "
  1231.   *
  1232.   type$ "book" =
  1233.   type$ "inbook" =
  1234.   or
  1235.     'author.editor.sort
  1236.     { type$ "proceedings" =
  1237.           'editor.sort
  1238.           'author.sort
  1239.       if$
  1240.     }
  1241.   if$
  1242.   #1 entry.max$ substring$            % added for newapa
  1243.   'sort.label :=                % added for newapa
  1244.   sort.label                    % added for newapa
  1245.   *
  1246.   "    "
  1247.   *
  1248.   title field.or.null
  1249.   sort.format.title
  1250.   *
  1251.   #1 entry.max$ substring$
  1252.   'sort.key$ :=
  1253. }
  1254.  
  1255. ITERATE {presort}
  1256.  
  1257. SORT    % sort by label, sort.label, title --- for final label calculation
  1258.  
  1259. STRINGS { last.label next.extra }
  1260.  
  1261. INTEGERS { last.extra.num }
  1262.  
  1263. FUNCTION {initialize.extra.label.stuff}
  1264. { #0 int.to.chr$ 'last.label :=
  1265.   "" 'next.extra :=
  1266.   #0 'last.extra.num :=
  1267. }
  1268.  
  1269. FUNCTION {forward.pass}
  1270. { last.label label =
  1271.      { last.extra.num #1 + 'last.extra.num :=
  1272.        last.extra.num int.to.chr$ 'extra.label :=
  1273.      }
  1274.      { "a" chr.to.int$ 'last.extra.num :=
  1275.        "" 'extra.label :=
  1276.        label 'last.label :=
  1277.     }
  1278.   if$
  1279. }
  1280.  
  1281. FUNCTION {reverse.pass}
  1282. { next.extra "b" =
  1283.     { "a" 'extra.label := }
  1284.      'skip$
  1285.   if$
  1286.   label extra.label * "}" * 'label :=   
  1287.   extra.label 'next.extra :=
  1288. }
  1289.  
  1290. EXECUTE {initialize.extra.label.stuff}
  1291.  
  1292. ITERATE {forward.pass}
  1293.  
  1294. REVERSE {reverse.pass}
  1295.  
  1296. FUNCTION {bib.sort.order}
  1297. { sort.label
  1298.   "    "
  1299.   *
  1300.   year field.or.null sortify
  1301.   *
  1302.   "    "
  1303.   *
  1304.   title field.or.null
  1305.   sort.format.title
  1306.   *
  1307.   #1 entry.max$ substring$
  1308.   'sort.key$ :=
  1309. }
  1310.  
  1311. ITERATE {bib.sort.order}
  1312.  
  1313. SORT         % by sort.label, year, title --- giving final bib. order.
  1314.  
  1315. FUNCTION {begin.bib}
  1316.  
  1317. { preamble$ empty$
  1318.     'skip$
  1319.     { preamble$ write$ newline$ }
  1320.   if$
  1321.   "\begin{thebibliography}{}" write$ newline$
  1322. }
  1323.  
  1324. EXECUTE {begin.bib}
  1325.  
  1326. EXECUTE {init.state.consts}
  1327.  
  1328. ITERATE {call.type$}
  1329.  
  1330. FUNCTION {end.bib}
  1331. { newline$
  1332.   "\end{thebibliography}" write$ newline$
  1333. }
  1334.  
  1335. EXECUTE {end.bib}
  1336.